/*
 * Catalogue.java
 *
 * Created on 7 May 2007, 23:57
 * Copyright (C) 2007   Yuezhong Zhang
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package usyd.comp5348;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 * Entity class Catalogue
 *
 * @author Yuezhong Zhang
 * @since version v 2.0 for assignemt 2
 * change made to
 * 1 : add column name for each field
 * 2 : add naming query for easy access entity bean
 * 3 : add CatalogueInfo file to prevent remote access entity bean
 *     so that entity bean never get exist in remote site
 * 4 : add java doc comments
 *
 * @author Henry Petersen
 * Original version v1.0 for assignment 1
 */
@Entity(name="Catalogue")
@NamedQueries(
{
    @NamedQuery(
    name="queryByCatalogueNumber",
            query="SELECT c FROM Catalogue c WHERE c.catalogueNumber = :catalogueNumber"
            ),
            @NamedQuery(
    name="queryByDirector",
            query="SELECT c FROM Catalogue c WHERE c.director = :director"
            ),
            @NamedQuery(
    name="queryByGenre",
            query="SELECT c FROM Catalogue c WHERE c.genre = :genre"
            )
}
)
public class Catalogue implements Serializable {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    
    /** Creates a new instance of Catalogue */
    public Catalogue() {
    }
    
    /**
     * Gets the id of this Catalogue.
     * @return the id
     */
    public Integer getId() {
        return this.id;
    }
    
    /**
     * Sets the id of this Catalogue to the specified value.
     * @param id the new id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    
    /**
     * Returns a hash code value for the object.  This implementation computes
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }
    
    /**
     * Determines whether another object is equal to this Catalogue.  The result is
     * <code>true</code> if and only if the argument is not null and is a Catalogue object that
     * has the same id field values as this object.
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Catalogue)) {
            return false;
        }
        Catalogue other = (Catalogue)object;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
        return true;
    }
    
    /**
     * Returns a string representation of the object.  This implementation constructs
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "usyd.comp5348.Catalogue[id=" + id + "]";
    }
    
    /**
     * Holds value of property catalogueNumber.
     */
    @Column(name="catalogueNumber")
    private String catalogueNumber;
    
    /**
     * Getter for property catalogueNumber.
     * @return Value of property catalogueNumber.
     */
    public String getCatalogueNumber() {
        return this.catalogueNumber;
    }
    
    /**
     * Setter for property catalogueNumber.
     * @param catalogueNumber New value of property catalogueNumber.
     */
    public void setCatalogueNumber(String catalogueNumber) {
        this.catalogueNumber = catalogueNumber;
    }
    
    /**
     * Holds value of property title.
     */
    @Column(name="title")
    private String title;
    
    /**
     * Getter for property title.
     * @return Value of property title.
     */
    public String getTitle() {
        return this.title;
    }
    
    /**
     * Setter for property title.
     * @param title New value of property title.
     */
    public void setTitle(String title) {
        this.title = title;
    }
    
    /**
     * Holds value of property director.
     */
    @Column(name="director")
    private String director;
    
    /**
     * Getter for property director.
     * @return Value of property director.
     */
    public String getDirector() {
        return this.director;
    }
    
    /**
     * Setter for property director.
     * @param director New value of property director.
     */
    public void setDirector(String director) {
        this.director = director;
    }
    
    /**
     * Holds value of property genre.
     */
    @Column(name="genre")
    private String genre;
    
    /**
     * Getter for property genre.
     * @return Value of property genre.
     */
    public String getGenre() {
        return this.genre;
    }
    
    /**
     * Setter for property genre.
     * @param genre New value of property genre.
     */
    public void setGenre(String genre) {
        this.genre = genre;
    }
    
    /**
     * Holds value of property price.
     */
    @Column(name="price")
    private float price;
    
    /**
     * Getter for property price.
     * @return Value of property price.
     */
    public float getPrice() {
        return this.price;
    }
    
    /**
     * Setter for property price.
     * @param price New value of property price.
     */
    public void setPrice(float price) {
        this.price = price;
    }
    
}
